//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#include <buola/app/cregistryfolder.h>
#include <buola/app/cregistry.h>

namespace buola {

CRegistryFolder::CRegistryFolder(CRegistry *pRegistry,const std::string &pPath)
    :   mProxy(&pRegistry->Proxy())
    ,   mPath(pPath)
{}

CRegistryFolder::CRegistryFolder(const std::string &pPath)
    :   mProxy(&get_registry().Proxy())
    ,   mPath(pPath)
{}

bool CRegistryFolder::GetValue(const std::string &pKey,UValue &pValue)
{
    pValue=mProxy->Call<UValue(std::string,std::string)>("GetValue",mPath,pKey);
    return !pValue.empty();
}

void CRegistryFolder::SetValue(const std::string &pKey,const UValue &pValue)
{
    mProxy->Call<void(std::string,std::string,UValue)>("SetValue",mPath,pKey,pValue);
}

std::vector<std::string> CRegistryFolder::GetKeyList()
{
    msg_info() << "should get key list!!!\n";
    return std::vector<std::string>();
//     PMessage lReply=mProxy.Call("org.buola.BigBrother.Conf","GetKeyList");
//     lReply->Extract(pList);
//     msg_info() << "got list " << pList.size() << "\n";
}

CRegistryMap CRegistryFolder::GetKeyValueMap()
{
    return mProxy->Call<CRegistryMap(std::string)>("GetKeyValueList",mPath);
}

/*namespace buola*/ }
